package org.bsplus.rpc.impl;

import java.util.List;
import javax.annotation.Resource;
import org.bsplus.domain.Project;
import org.bsplus.rpc.ProjectRPCService;
import org.bsplus.rpc.dto.ProjectDTO;
import org.bsplus.service.ProjectService;
import org.bsplus.util.MappingUtils;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.transaction.annotation.Transactional;

@Transactional
public class ProjectRPCServiceImpl implements ProjectRPCService
{
    private ProjectService projectService;
    
    private MappingUtils mappingUtils;

    @Override
    public List<ProjectDTO> getAllProjects()
    {
        List<Project> projects = projectService.getAllProjects();

        return mappingUtils.map(projects, ProjectDTO.class);
    }

    @Resource
    @Required
    public void setProjectService(ProjectService projectService)
    {
        this.projectService = projectService;
    }

    @Resource
    @Required
    public void setMappingUtils(MappingUtils mappingUtils)
    {
        this.mappingUtils = mappingUtils;
    }
}
